<% if session[:user_id] %>	
	<h1>Cajas disponibles</h1>

	<table border=1>
		<tr>
		  <th>Título</th>
		  <th>Descripcion</th>
		  <th>Formato ATX</th>
		  <th>Dimensiones</th>
		  <th>URL</th>
		  <th>Precio</th>
		  <th></th>
		  <th></th>
		  <th></th>
		</tr>

	<% @boxes.each do |box| %>
		<tr>
		  <td><%= box.title %></td>
		  <td><%= box.description %></td>
    <td class="center"><%= box.format %></td>
    <td class="center"><%= box.dimensions %></td>
    <td><%= link_to box.product_url, box.product_url, :target => '_blank' %></td>
    <td class="center"><%= box.price %></td>
		  <td><%= link_to 'Mostrar', box %></td>
		  <td><%= link_to 'Editar', edit_box_path(box) %></td>
		  <td><%= link_to 'Eliminar', box, method: :delete, data: { confirm: '¿Está seguro?' } %></td>
		</tr>
	<% end %>
	</table>

	<br />

	<%= link_to 'Nueva caja', new_box_path %>
<% else %>
	<% if notice %>
	<p id="notice"><%= notice %></p>
	<% end %>

	<h1>Catalogo de cajas</h1>

	<% @boxes.each do |box| %>
		<div class="entry">
			<h3><%= box.title %></h3>
			<%= sanitize(box.description) %>
			<div class="price_line">
				<span class="price"><%= number_to_currency(box.price) %></span>
				<% prod = Product.find(:first, :conditions => ["heir_id = ? and heir_type = ?",box.id, 'Box']) %>
				<%= button_to 'Añadir a la configuracion', line_products_path(product_id: prod.id) %>
			</div>
		</div>
	<% end %>
<% end %>
